package com.eclink.iot.producer.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    // 获取动态端口
    @Autowired
    private ServletWebServerApplicationContext context;

    @RequestMapping("/getnamebyid")
    public String getNameById(Integer id) {
        return "provider-name " + id +
                "server-port " + context.getWebServer().getPort();
    }
}
